package com.company.regist.servlet;



import com.company.regist.dao.FriendsDAOImpl;
import com.company.regist.dao.IFriendsDAO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.company.regist.pojo.Fridends;

@WebServlet("/showfriend")
public class ShowFriendServlet extends HttpServlet
{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

		resp.setHeader("Content-Type","text/html;charset=utf-8");
		resp.getWriter().print("我的朋友圈");
		IFriendsDAO dao = new FriendsDAOImpl();
		List<Fridends> list=new ArrayList<>();
		try {
			list =  dao.showFriend();
			System.out.println(list.toArray());
			if(list!=null)
			{
				Iterator<Fridends> it = list.iterator();
				         while (it.hasNext()) {
							 Fridends str = (Fridends) it.next();
							 resp.getWriter().println(str+"<br />");
				        }

			}
			else
			{
				resp.getWriter().print("find fail");
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		

		
		
	}
	

}
